<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-row>
        <el-col :span="9">
          <el-form-item label="制度文号" prop="systemNumber">
            <el-input size="small" v-model="queryParams.systemNumber" clearable placeholder="请选择制度文号"/>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item label="制度名称" prop="systemName">
            <el-input size="small" v-model="queryParams.systemName" clearable placeholder="请选择制度名称"/>
          </el-form-item>
        </el-col>
        <el-col :span="6" style="text-align: right">
          <el-form-item>
            <el-button type="primary" size="small" @click="handleQuery">查询</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row :gutter="30">
      <el-table :data="institutionList" border ref="multipleTable"
                @selection-change="handleSelectionChange" :row-key="getRowKeys"
      >
        <el-table-column type="selection" :reserve-selection="true"></el-table-column>
        <el-table-column label="序号" width="50px" type="index"/>
        <el-table-column label="制度文号" align="center" key="systemNumber" prop="systemNumber"/>
        <el-table-column label="制度名称" align="center" key="systemName" prop="systemName"/>
        <el-table-column label="制度编号" align="center" key="systemCode" prop="systemCode"/>
<!--        <el-table-column label="制度内容" align="center" key="systemPurpose" prop="systemPurpose"/>-->
        <el-table-column label="编制部门" align="center" key="superintendent" prop="superintendent" width="130px"/>
        <el-table-column label="签发日期" align="center" key="issueDate" prop="issueDate" width="130px"/>
        <el-table-column label="附件" align="center" key="name" prop="name" width="80px"/>
      </el-table>
      <div class="text-center mar-top-20">
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </el-row>
  </div>
</template>

<script>
import { listInstitution } from '@/api/lc/institution'

export default {
  name: 'chooseInstitutionTable',
  data() {
    return {
      // 表格数据
      institutionList: [],
      total: 0,
      totalPage: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        systemNumber: ''
      },
      //记录每行的key值
      getRowKeys(row) {
        return row.riskId
      },
      multipleSelection: [], // 表格选中
      select_number: '', //表格select选中的条数
      select_Id: [] //表格select复选框选中的id
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    init() {
      this.institutionList = []
      this.total = 0
      this.totalPage = 0,
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          systemNumber: ''
        }
      this.multipleSelection = []
      this.select_number = ''
      this.select_Id = []
      this.getList()
      this.$refs.multipleTable.clearSelection()
    },
    /** 查询合规风险提示库列表 */
    getList() {
      this.loading = true
      listInstitution(this.queryParams).then(response => {
        this.institutionList = response.rows
        this.total = response.total
      })
    },
    handleSelectionChange(rows) {
      this.multipleSelection = rows
      this.select_number = this.multipleSelection.length
      this.select_Id = []
      if (rows) {
        rows.forEach((row) => {
          if (row) {
            this.select_Id.push(row.id)
          }
        })
      }
      this.$emit('checkData', this.multipleSelection)
    },
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
  }
}
</script>

<style scoped>

</style>
